Skip to content

feat(auth): implement GitHub OAuth to distribute API rate limits across authenticated users - #5744

Merged
JhaSourav07 merged 11 commits into
JhaSourav07:mainfrom
kanishka-2007-tech:Oauth
Jun 15, 2026
Merged

feat(auth): implement GitHub OAuth to distribute API rate limits across authenticated users#5744
JhaSourav07 merged 11 commits into
JhaSourav07:mainfrom
kanishka-2007-tech:Oauth

Conversation

@kanishka-2007-tech

@kanishka-2007-tech kanishka-2007-tech commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Description

This PR introduces GitHub OAuth authentication to reduce dependency on the application's global Personal Access Token (PAT) and prevent rate-limit exhaustion under high traffic.

Authenticated users can now sign in with GitHub, allowing dashboard-related GitHub API requests to be performed using their personal OAuth access token. The existing server PAT is retained as a fallback for unauthenticated users and README SVG generation endpoints.

Solution

Implemented GitHub OAuth authentication using NextAuth.

  • Authentication Flow
  • Added Sign in with GitHub functionality.
  • Users can authenticate via GitHub OAuth.
  • GitHub access tokens are stored securely in the session/JWT.
  • Dashboard requests automatically use the authenticated user's token.
  • Unauthenticated requests continue using the server PAT as a fallback.

Fixes #3679

Pillar

  • 🎨 Pillar 1 — New Theme Design
  • 📐 Pillar 2 — Geometric SVG Improvement
  • 🛠️ Other (Bug fix, refactoring, docs)

Checklist before requesting a review:

  • I have read the CONTRIBUTING.md file.
  • I have tested these changes locally (localhost:3000/api/streak?user=YOUR_USERNAME).
  • I have run npm run format and npm run lint locally and resolved all errors (CI will fail otherwise).
  • My commits follow the Conventional Commits format (e.g., feat(themes): ..., fix(calculate): ...).
  • I have updated README.md if I added a new theme or URL parameter.
  • I have started the repo.
  • I have made sure that i have only one commit to merge in this PR.
  • The SVG output matches the CommitPulse "premium quality" aesthetic standard (no raw elements, smooth animations, correct fonts).
  • (Recommended) I joined the CommitPulse Discord community for contributor discussions, mentorship, and faster PR support.

@vercel

vercel Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

@kanishka-2007-tech is attempting to deploy a commit to the jhasourav07's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added the status:blocked This PR is blocked due to a failing CI check. label Jun 15, 2026
@github-actions github-actions Bot removed the status:blocked This PR is blocked due to a failing CI check. label Jun 15, 2026
@github-actions

github-actions Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

📦 Next.js Bundle Size Report (Gzipped Sizes)

Asset PR Size Base Size Difference Status
static/chunks/app/api/Auth/Nextauthgithub/route-[hash].js 0.19 KB - +0.19 KB (++100%) 🆕 New

📊 Summary of Totals

Category PR Size Base Size Difference
Total JS 3434.17 KB 3433.75 KB +0.41 KB (+0.01%)
Total CSS 258.05 KB 258.05 KB 0 B

@Aamod007 Aamod007 added level:advanced Complex contributions involving architecture, optimization, or significant feature work type:feature New features, additions, or enhancements type:devops CI/CD pipelines, workflows, dev scripts, and config type:security Security fixes, dependency updates, or hardening mentor:Aamod007 labels Jun 15, 2026

@Aamod007 Aamod007 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a solid OAuth/token-plumbing change, but it is currently blocked by the Vercel check waiting for team authorization. The status context points to the deploy authorization link, so please get that approved and rerun checks before we can merge. The code paths to recheck after that are auth.ts, lib/githubtoken.ts, and the token wiring in app/(root)/dashboard/[username]/page.tsx, app/(root)/dashboard/org/[orgname]/page.tsx, and app/api/stats/route.ts.

@Aamod007 Aamod007 added the gssoc:approved PR has been reviewed and accepted for valid contribution points label Jun 15, 2026

@Aamod007 Aamod007 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This OAuth/token plumbing is cohesive and the test/utility updates line up with the new auth flow. The changes in auth.ts, lib/githubtoken.ts, lib/github.ts, and the dashboard/API callers are consistent, so I’m happy to approve this now.

@github-actions github-actions Bot added this to the GSSoC 2026 milestone Jun 15, 2026
@kanishka-2007-tech

Copy link
Copy Markdown
Contributor Author

@Aamod007 I think this PR deserves the label : critical . 😃

@Aamod007 Aamod007 added level:critical High-priority or mission-critical contributions affecting core systems, security, or infrastructure quality:exceptional Outstanding contribution with exceptional implementation quality, testing. and removed level:advanced Complex contributions involving architecture, optimization, or significant feature work labels Jun 15, 2026
@Aamod007

Copy link
Copy Markdown
Collaborator

@Aamod007 I think this PR deserves the label : critical . 😃

my bad

@JhaSourav07
JhaSourav07 merged commit 248542f into JhaSourav07:main Jun 15, 2026
5 of 6 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🎉 Congratulations @kanishka-2007-tech! Your PR has been successfully merged. 🚀

Thank you for contributing to CommitPulse. Your work helps us build a better tool for the community.

⚠️ Important for GSSoC Contributors:
You are strictly advised to join our Discord Server as it is mandatory for all GSSoC participants. All important announcements, point claims, and community discussions happen there.

Keep building! 💻✨

@JhaSourav07 JhaSourav07 added gssoc:approved PR has been reviewed and accepted for valid contribution points and removed gssoc:approved PR has been reviewed and accepted for valid contribution points labels Jun 17, 2026
MasterJi27 pushed a commit to MasterJi27/commitpulse that referenced this pull request Jul 4, 2026
…ts across authenticated users (JhaSourav07#5744)

## Description

This PR introduces GitHub OAuth authentication to reduce dependency on
the application's global Personal Access Token (PAT) and prevent
rate-limit exhaustion under high traffic.

Authenticated users can now sign in with GitHub, allowing
dashboard-related GitHub API requests to be performed using their
personal OAuth access token. The existing server PAT is retained as a
fallback for unauthenticated users and README SVG generation endpoints.

## Solution

Implemented GitHub OAuth authentication using NextAuth.

- Authentication Flow
- Added Sign in with GitHub functionality.
- Users can authenticate via GitHub OAuth.
- GitHub access tokens are stored securely in the session/JWT.
- Dashboard requests automatically use the authenticated user's token.
- Unauthenticated requests continue using the server PAT as a fallback.

Fixes JhaSourav07#3679 

## Pillar

- [x] 🎨 Pillar 1 — New Theme Design
- [x] 📐 Pillar 2 — Geometric SVG Improvement
- [x] 🛠️ Other (Bug fix, refactoring, docs)

## Checklist before requesting a review:

- [x] I have read the `CONTRIBUTING.md` file.
- [x] I have tested these changes locally
(`localhost:3000/api/streak?user=YOUR_USERNAME`).
- [x] I have run `npm run format` and `npm run lint` locally and
resolved all errors (CI will fail otherwise).
- [x] My commits follow the Conventional Commits format (e.g.,
`feat(themes): ...`, `fix(calculate): ...`).
- [x] I have updated `README.md` if I added a new theme or URL
parameter.
- [x] I have started the repo.
- [ ] I have made sure that i have only one commit to merge in this PR.
- [x] The SVG output matches the CommitPulse "premium quality" aesthetic
standard (no raw elements, smooth animations, correct fonts).
- [x] (Recommended) I joined the CommitPulse Discord community for
contributor discussions, mentorship, and faster PR support.
@kanishka-2007-tech
kanishka-2007-tech deleted the Oauth branch July 7, 2026 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved PR has been reviewed and accepted for valid contribution points level:critical High-priority or mission-critical contributions affecting core systems, security, or infrastructure mentor:Aamod007 quality:exceptional Outstanding contribution with exceptional implementation quality, testing. type:devops CI/CD pipelines, workflows, dev scripts, and config type:feature New features, additions, or enhancements type:security Security fixes, dependency updates, or hardening

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: GitHub OAuth Integration

3 participants